package com.fh.modules.oms;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * @Description: 订单状态
 * @author： qiujunda
 * @date： 2019/10/10 22:35
 */
public enum OrderStatus {
    /**已取消*/
    CANCELLED(0,"已取消"){
        public String text(){
            return "已取消";
        }
    },

    /**未付款*/
    NOT_PAY(1,"未付款"){
        public String text(){
            return "未付款";
        }
    },

    /**付款确认中*/
    PAY_CONFIRMING(2,"付款确认中"){
        public String text(){
            return "付款确认中";
        }
    },

    /**待发货，已付款*/
    PAY_SUCCESS(3,"已付款"){
        public String text(){
            return "已付款";
        }
    },

    /**已发货*/
    SENDED(4,"已发货"){
        public String text(){
            return "已发货";
        }
    },

    /**已完成*/
    FINISHED(5,"已完成"){
        public String text(){
            return "已完成";
        }
    },

    /**已关闭*/
    CLOSED(6,"已关闭"){
        public String text(){
            return "已关闭";
        }
    },

    /**退货中*/
    REFUNDING(7,"退货中"){
        public String text(){
            return "退货中";
        }
    },

    /**已退货*/
    REFUNDED(8,"已退货"){
        public String text(){
            return "已退货";
        }
    };

    public static Map<OrderStatus, Set<OrderStatus>> STATUS_PROCESS;
    static{
        STATUS_PROCESS=new HashMap<>(9) ;
        //未付款->已取消，付款确认中，已付款
        Set<OrderStatus> notPay=new HashSet<OrderStatus>(3);
        notPay.add(CANCELLED);notPay.add(PAY_CONFIRMING);notPay.add(PAY_SUCCESS);

        //付款确认中->已付款
        Set<OrderStatus> payConfirming=new HashSet<OrderStatus>(1);
        payConfirming.add(PAY_SUCCESS);

        //已付款->已发货，已完成，已关闭，退货中
        Set<OrderStatus> paySuccess=new HashSet<OrderStatus>(4);
        paySuccess.add(SENDED);paySuccess.add(FINISHED);paySuccess.add(CLOSED);paySuccess.add(REFUNDING);

        //已发货->已完成，已关闭，退货中
        Set<OrderStatus> sended=new HashSet<OrderStatus>(3);
        sended.add(FINISHED);sended.add(CLOSED);sended.add(REFUNDING);

        //已完成->已关闭,退货中
        Set<OrderStatus> finished=new HashSet<OrderStatus>(2);
        finished.add(CLOSED);finished.add(REFUNDING);

        //退货中->已完成，已退货
        Set<OrderStatus> refunding=new HashSet<OrderStatus>(2);
        refunding.add(FINISHED);refunding.add(REFUNDED);

        STATUS_PROCESS.put(NOT_PAY,notPay);
        STATUS_PROCESS.put(PAY_CONFIRMING,payConfirming);
        STATUS_PROCESS.put(PAY_SUCCESS,paySuccess);
        STATUS_PROCESS.put(SENDED,sended);
        STATUS_PROCESS.put(FINISHED,finished);
        STATUS_PROCESS.put(REFUNDING,refunding);
    }

    private int value;

    private String name;

    OrderStatus(int value){
        this.value=value;
    }
    OrderStatus(int value,String name){
        this.value=value;
        this.name=name;
    }

    public int getValue() {
        return this.value;
    }

    public String getName(){
        return this.name;
    }
}
